<template>
	<view class="warp">
		<!-- ref和show属性一定要设置的 -->
		<!-- 先缩小再放大，在缩小 -->
		<uni-transition ref="one" mode-class="fade" custom-class="div1 shake-effect" :show="true">
			
		</uni-transition>

	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				
			}
		},
		onLoad() {
			// 调用动画函数
			setTimeout(()=>{
				this.starAni()
				
			},100)
			setTimeout(()=>{
				uni.switchTab({
					url:'/pages/index/index'
				})
				
			},8000)
			
		},
		// mounted() {
		// 	this.starAni()
		// },
		methods: {
			// 创建动画函数
			starAni(){
				//必须确认ref获取成功
				// console.log(this.$refs.one);
				//1
					this.$refs.one.step({
						scale :100,
						backgroundColor:'white'
					},{
						duration:3000,
					})
					this.$refs.one.step({
						opacity: 1,
						scale :1,
						backgroundColor:'deepskyblue'
					},{
						timingFunction: 'linear',
						duration: 3000
					})
					this.$refs.one.step({
						scale :1.5,
					},{
						timingFunction: 'ease-in',
						duration: 500
					})
					this.$refs.one.step({
						scale :1,
					})
					// 执行动画
					this.$refs.one.run();
					
			}
		}
	}
</script>

<style lang="scss">
	.warp{
		width: 100%;
		height: calc(93vh);
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #d13838;
		position: relative;
		background-image: url('../../static/ad1178fd5f151e23ac425859e19b0a10.jpeg');
		background-size: 100% 100%;
		.div1{
			width: 100px;
			height: 100px;
			background-color: deepskyblue;
			border-radius: 6px;
			
		}
		@keyframes shake {
		  0% { transform: scale(0.9); }
		  25% { transform: scale(1); }
		  50% { transform: scale(0.9); }
		  75% { transform: scale(1); }
		  100% { transform: scale(0.9); }
		}
		 
		.shake-effect {
		  animation: shake 0.1s; /* 0.5秒内完成颤抖效果 */
		  animation-iteration-count: 20; /* 动画无限次数执行 */
		}
	}
</style>
